package Scuttlebutt;

import java.awt.event.*;
import javax.swing.*;

public class EventConnect extends JMenuItem implements ActionListener 
{
	Scuttlebutt parent = null;

	public EventConnect(Scuttlebutt parent)
	{
		this.parent = parent;
		addActionListener(this);
	}

	
	
	public EventConnect(String text, Scuttlebutt parent)
	{
		super(text);
		this.parent = parent;
		addActionListener(this);
	}


	public void actionPerformed(ActionEvent a0)
	{
		if(parent.isConnected()){
			parent.close();
		}else{
			parent.setWaitCursor(true);
			parent.getButtonBar().getConnectButton().setEnabled(false);
			parent.connect();
			parent.setTitle();
			parent.getButtonBar().getConnectButton().setEnabled(true);
			parent.getButtonBar().enableSaveProjectButton(true);
			parent.getButtonBar().enableCloseProjectButton(true);
			parent.setWaitCursor(false);
			
/*			parent.setWaitCursor(true);
			System.out.println("EventConnect");
			parent.getButtonBar().getConnectButton().setEnabled(false);
//			parent.getButtonBar().enableSaveProjectButton(false);
//			parent.getButtonBar().enableCloseProjectButton(false);
			parent.();
			parent.connect();
			parent.setTitle();
			parent.getButtonBar().getConnectButton().setEnabled(true);
			parent.getButtonBar().enableSaveProjectButton(true);
			parent.getButtonBar().enableCloseProjectButton(true);
			parent.setWaitCursor(false);*/
		}
	}
}

